# 指定编译器最小版本
cmake_minimum_required(VERSION 3.10)

#项目工程名
project(arm_linux_gcc C CXX ASM)
set(TARGET_NAME TONGYI)

#指定编译平台/架构与语言标准
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

#指定工具链
# set(CMAKE_C_COMPILER "arm-openwrt-linux-gcc")
# set(CMAKE_CXX_COMPILER "arm-openwrt-linux-g++")
# set(CMAKE_AS_COMPILER "arm-openwrt-linux-gcc")

set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_AS_COMPILER "gcc")

#设置编译优化选项
set(OPTIMIZE_FLAGS -g -Og)

#预处理开关
# add_compile_definitions(__SOFTFP__)


#添加源文件
set(incs "app/inc"
        "component/EasyLogger/inc/" 
)

file(GLOB srcs
    "app/src/*.c"
)

include_directories(${incs})

# 添加要引用的库的子目录
add_subdirectory(component/EasyLogger/)

# 添加主目标
add_executable("${TARGET_NAME}" ${srcs})

# 将子组件链接到主目标
target_link_libraries("${TARGET_NAME}" EasyLogger)

#添加自定义命令
# add_custom_command(
#     TARGET "${TARGET_NAME}.elf" POST_BUILD
#     COMMAND objcopy -O ihex "${TARGET_NAME}.elf" "${TARGET_NAME}.hex"
#     COMMAND objcopy -I ihex -O binary "${TARGET_NAME}.hex" "${TARGET_NAME}.bin"
# )
